#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits>

using namespace std;

void print_vector(vector<int>& a)
{
    for (int i = 0; i<a.size(); ++i)
    {
        cout<<a[i];
    }
}

void get_way(vector< pair<int, double> >& pred, int from, int to, vector<int>& way)
{
    int n = pred.size();
    way.clear();
    if (pred[to].first == -1) return;
    int curr_vert = to;
    while (curr_vert != from)
    {
        way.push_back(curr_vert);
        curr_vert = pred[curr_vert].first;
    }
    way.push_back(from);
    reverse(way.begin(), way.end());
}

void dejkstra(vector< map<int, double> >& g, vector< pair<int, double> >& pred, int from, int to)
{
    int n = g.size();
    vector<bool> was;
    was.assign(n, false);
    pred.assign(n, make_pair(-1, numeric_limits<double>::max()));
    pred[from] = make_pair(from, 0);
    multimap<double, int> pri_queue;
    pri_queue.insert(make_pair(0, from));
    while (!pri_queue.empty())
    {
        int curr = pri_queue.begin()->second;
        double length = pri_queue.begin()->first;
        pri_queue.erase(pri_queue.begin());
        if (curr == to) return;
        if (was[curr]) continue;
        was[curr] = true;
        for (map<int, double>::iterator iter = g[curr].begin(); iter != g[curr].end(); ++iter)
        {
            if (pred[iter->first].second > length + iter->second)
            {
                pred[iter->first].second = length + iter->second;
                pred[iter->first].first = curr;
                pri_queue.insert(make_pair(pred[iter->first].second, iter->first));
            }
        }
    }
}


void find_second_way(vector< map<int, double> >& g, int from, int to)
{
    double res = -1;
    vector< pair<int, double> > pred;
    dejkstra(g, pred, from, to);
    vector<int> way;
    get_way(pred, from, to, way);
    if (way.empty())
    {
        cout<<"NO";
        return;
    }
    vector<int> res_way;
    for (int i = 0; i<way.size()-1; ++i)
    {
        int from_temp = way[i];
        int to_temp = way[i+1];
        double weight = g[from_temp][to_temp];
        g[from_temp].erase(to_temp);
        pred.clear();
        vector<int> temp_way;
        dejkstra(g, pred, from, to);
        if (pred[to].first != -1)
            if (res == -1 || res > pred[to].second)
            {
                res = pred[to].second;
                get_way(pred, from, to, res_way);
            }
        g[from_temp][to_temp] = weight;
    }
    if (res == -1)
    cout << "NO";
    else
    cout << "YES "<< res<<endl;
    return;
}

int main()
{
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int n;
    cin>>n;
    vector< map<int, double> > g;
    g.resize(n);
    int from, to;
    cin>>from>>to;
    int from_temp, to_temp;
    double weight_temp;
    while(cin>>from_temp>>to_temp>>weight_temp)
    {
        g[from_temp][to_temp] = weight_temp;
    }
    find_second_way(g, from, to);
    return 0;
}
